<template>
  <div class="contain">
    <div class="content">
      <div class="title">错题集</div>
      <div v-for="(item,index) in lists" :key="index">
        <div class="question-info">
          <div class="collect-item">

            <div @click="changeNav">
              <a-icon class="star-icon" type="form"/>
              <span>同类练习</span>
            </div>
            <div @click="delQuestion(item,index)">
              <a-icon class="star-icon" type="delete"/>
              <span>移除本题</span>
            </div>
            <!--<div>
              <a-icon class="star-icon" type="star"/>
              <span>收藏本题</span>
            </div>-->

          </div>
          <div class="title">{{ index + 1 }}.{{item.question_content}}</div>
          <div>
            <a-form>
              <a-form-item class="radio-item">
                <a-radio-group v-decorator="['radio-group']">
                  <a-radio value="a">
                    {{item.choiceqst_op1}}
                  </a-radio>
                  <a-radio value="b">
                    {{item.choiceqst_op2}}
                  </a-radio>
                  <a-radio value="c">
                    {{item.choiceqst_op3}}
                  </a-radio>
                  <a-radio value="d">
                    {{item.choiceqst_op4}}
                  </a-radio>
                </a-radio-group>
              </a-form-item>
            </a-form>
          </div>
          <div class="check-detail" @click="item.showDetail=!item.showDetail">提交答案查看解析</div>

        </div>
        <div v-show="item.showDetail">
          <div class="analysis-info">
            <div class="answer-right">
              <div>
                <img src="@/assets/image/icons/error.png" alt="">
                <span class="right-title">正确答案</span><span class="right-answer">D</span>
                <span class="your-title">你的答案</span><span class="error-answer">B</span>
              </div>
              <div class="right-percent">
                全站正确率：20%
              </div>
            </div>
            <div class="analysis-answer">
              <div>
                <div class="title">解析</div>

                <div class="content">这是解析这是解析这是解析这是解析这是解析这是解析这是解析这是解析</div>
              </div>
              <div>
                <div class="title">视频解析</div>
                <div class="content">
                  <video src="" controls></video>
                </div>
                <div class="video-tip">
                  <img src="@/assets/image/icons/video.png" alt=""><span>考查知识点（概念）</span>
                </div>
              </div>
            </div>
            <div class="has-ques">
              <div>
                优质答疑
              </div>
              <a class="right-percent">
                还有疑问？去提问
              </a>
            </div>

          </div>
          <div class="question-list" v-for="(item,index) in 3" :key="index">
            <span class="left-ask">问</span>
            <div class="content">
              <div class="square-item"></div>
              <div>
                <span class="title">标题：听不懂</span>
                <span class="date">2020-10-10 12:11</span>
              </div>
              <div>
                加强企业内部的沟通，使部门目标与公司整体目标趋于一致，才能产生最优决策。
              </div>
              <div><span>老实回答：</span><span class="teacher-answer">不会，总体来说难度不大，只要努力，相信自己可以的！！加油！！！</span></div>
            </div>
          </div>
        </div>
      </div>
      <div class="no-data" v-if="lists.length === 0">
        暂无数据
      </div>
    </div>
  </div>
</template>

<script>

export default {
  name: 'mistakeCollection',
  data() {
    return {
      lists: []
    }
  },
    props:{
        course: null
    },
    watch: {
        course() {
          this.init()
        },
    },
    mounted() {
        this.init()
    },
    methods:{
      init() {
          if(!this.course) return
          this.$api.ajaxData({
              authorization: true,
              pathName: 'getErrorQuesList_pc',
              data: {
                  course_id:this.course.id
              },
              method: 'post',
              errorFunc: false
          }).then(res => {
              this.lists = res.obj

          }).catch(()=>{
              this.lists = []
          })
      },
      changeNav() {
        this.$emit('switchNav',{
            component: 'qACenter'
        })
      },
      delQuestion(question,index) {
          this.$api.ajaxData({
              authorization: true,
              pathName: 'deleteErrorQues',
              data: {
                  err_quesId: question.id
              },
              method: 'post',
              errorFunc: false
          }).then(res => {
              if(res.code === 200) {
                  this.$util.alert(res.msg);
                  this.lists.splice(index,1);
              }

          }).catch(()=>{
              this.$util.alert('网络异常，请稍后重试')
          })
      }
    }

}
</script>

<style lang="scss" scoped>
.contain {
  padding: 10px 20px;
  background: #fff;
  border: 1px solid #f7f7f7;

  .content {
    & > div {
      margin-bottom: 20px;
    }

    & > .title {
      position: relative;
      padding-left: 10px;
      line-height: 1;

    }

    & > .title::before {
      position: absolute;
      content: '';
      height: 100%;
      width: 5px;
      background-color: #006ADE;
      top: 0;
      left: 0;
    }

    .title-box {
      height: 60px;
      border-bottom: 1px solid #f2f2f2;
      display: flex;
      align-items: center;
      color: #333333;
      font-weight: bold;
      padding: 0 40px;

      .border-item {
        border: 1px solid #0079fe;
        border-radius: 50%;
        padding: 3px;
        margin-right: 10px;


      }

      img {
        width: 14px;
        height: 14px;
        position: relative;
      }

      img::before {
        height: 30px;
        width: 30px;
        border-radius: 50%;
        border: 1px solid #0079fe;
        position: absolute;
        top: 0;
        left: 0;
      }

    }

    .question-info {
      padding: 0 30px;
      position: relative;
      &:after {
        content: '';
        display: block;
        clear: both;
      }
      .title {
        margin-bottom: 10px;
      }

      .collect-item {
        float: right;
        display: flex;
        margin: 10px 0 0;
        padding-left: 50px;
        & > div {
          display: flex;
          align-items: center;
          cursor: pointer;
        }
        .star-icon {
          color: #E3E3E3;
          font-size: 24px;

        }

        span {
          margin-left: 10px;
        }
      }

      .ant-radio-group > label {
        width: 100%;
        white-space: pre-wrap;
        &:not(:last-child) {
          margin-bottom: 10px;
        }
      }

      .pre-btn {
        margin-right: 40px;
      }

      .check-detail {
        float: right;
        border: 1px solid #C9C9C9;
        padding: 2px 10px;
      }
    }

    .analysis-info {
      padding: 1% 5%;
      position: relative;

      & > div {
        margin-bottom: 40px;
      }

      .answer-right {
        border: 1px solid #D7D7D7;
        display: flex;
        align-items: center;
        justify-content: space-between;
        position: relative;

        & > div:first-child {
          padding: 10px;
          height: 60px;

        }

        img {
          display: inline-block;
          margin-right: 50px;
          height: 30px;
          width: 30px;
        }

        .right-title, .your-title {
          margin-right: 20px;
        }

        .right-answer, .your-answer {
          margin-right: 40px;
        }

        .error-answer {
          font-size: 20px;
          color: #EA3324;

        }

        .right-answer {
          font-size: 20px;
          color: #000000;

        }

        .right-percent {
          background-color: #F2F2F2;
          position: absolute;
          color: #999999;
          right: -1px;
          top: -1px;
          height: 62px;
          line-height: 62px;
          padding: 0 10px;
        }

      }

      .analysis-answer {
        display: flex;

        & > div {
          padding: 20px;

          border: 1px solid #D7D7D7;

          .title {
            color: #666666;
            font-size: 16px;
            margin-bottom: 20px;
          }

          flex-basis: 50%;
        }

        & > div:first-child {
          border-right: none;
        }

        .video-tip {
          color: #2C68D6;
          font-size: 12px;
          margin-top: 20px;

          img {
            width: 21px;
            height: 17px;
            display: inline-block;
            margin-right: 10px;

          }
        }

      }

      .has-ques {
        height: 60px;
        border: 1px solid #D7D7D7;
        line-height: 60px;

        & > div {
          display: inline-block;
          height: 100%;

        }

        & > div:first-child {
          width: 200px;
          background: url("../../../assets/image/icons/blue-icon.png") no-repeat;
          background-position: 0 0;
          color: #fff;
          background-size: auto 100%;
          font-weight: bold;
          padding-left: 10px;
        }

        & > a {
          float: right;
          text-decoration: #006ADE;
          text-decoration: underline;
          margin-right: 40px;
          font-weight: bold;
        }
      }
    }

    .question-list {
      padding: 1% 5%;

      .left-ask {
        width: 33px;
        height: 33px;
        line-height: 33px;
        text-align: center;
        background-color: #83B3D6;
        color: #fff;
        font-weight: bold;
        border-radius: 50%;
        display: inline-block;
        vertical-align: top;
      }

      .content {
        border: 1px solid #D7D7D7;
        display: inline-block;
        width: calc(100% - 50px);
        margin-left: 17px;
        padding: 20px;
        position: relative;

        .square-item {
          transform: rotate(45deg);
          position: absolute;
          left: -8px;
          top: 14px;
          width: 14px;
          height: 14px;
          border: 1px solid #D7D7D7;
          border-top: 0px;
          border-right: 0px;
          background-color: #ffffff;
        }

        .title {
          color: #333333;
          font-weight: bold;
          max-width: 80%;
          white-space: pre-wrap;
          display: inline-block;
        }

        .date {
          float: right;
        }

        .teacher-answer {
          color: #006ADE;
        }

        & > div:not(:first-child) {
          margin-bottom: 20px;
        }
      }
    }
  }
  .no-data {
    text-align: center;
  }
}


</style>